﻿using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

using Gonte.Wpf.Controls.ViewModel;

using MyWpfControlsTestBench.Model;

namespace MyWpfControlsTestBench.ViewModel
{
    public class RootTreeItemViewModel
        : ViewModelTemplate<RootTreeItem>
    {
        #region Read Only

        internal readonly BitmapImage IconImage = new BitmapImage(new Uri(@"pack://application:,,/Images/Root.jpg"));

        #endregion

        public RootTreeItemViewModel()
            : base(new RootTreeItem(), null, false)
        {
            IconSource = IconImage;
        }

        public override bool AddChild(ViewModelBase viewModel)
        {
            ChildTreeItemViewModel childViewModel = (ChildTreeItemViewModel)viewModel;

            ConcreteModel.Children.Add(childViewModel.ConcreteModel);

            return base.AddChild(viewModel);
        }

        public override void OnPropertyChanged(String propertyName, Object oldValue)
        {
            if (propertyName.Equals("Name"))
            {
                base.OnPropertyChanged("Label");
            }
        }

        public override String Label
        {
            get { return "Root Item"; }
            set { }
        }

        public override ContextMenu CreateContextMenu()
        {
            return new ContextMenu();
        }
    }
}
